package demo;

import java.util.ArrayList;

/*
class Login {
    private String userName;
    private String passWord;

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassWord() {
        return passWord;
    }

    public void setPassWord(String passWord) {
        this.passWord = passWord;
    }

    public  void logInfo(String userName, String passWord) {
        if(!this.userName.equals(userName)) {
            System.out.println("用户名错误！");
            return;
        }

        if(!this.passWord.equals(passWord)) {
            System.out.println("密码错误！");
            return;
        }

        System.out.println("登录成功！");

    }
}
*/
class Login {
    private String userName;
    private String passWord;

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassWord() {
        return passWord;
    }

    public void setPassWord(String passWord) {
        this.passWord = passWord;
    }

    public  void logInfo(String userName, String passWord) throws UserNameException, PassWordException {
        if(!this.userName.equals(userName)) {
            throw new UserNameException("用户名错误异常.....");
        }

        if(!this.passWord.equals(passWord)) {
            throw new PassWordException("密码错误异常....");
        }


       /* try {
            if(!this.passWord.equals(passWord)) {
                throw new PassWordException("密码错误异常.....");
            }
        }catch (PassWordException e) {

        }*/


        System.out.println("登录成功！");

    }
}

public class Test {
    public static void main(String[] args) {
        Login login = new Login();
        login.setUserName("abc");
        login.setPassWord("123");
        /*
        login.logInfo("abc7", "123");
        */

        try {
            login.logInfo("abc7", "123");
        }catch (UserNameException e) {
            e.printStackTrace();
        }catch (PassWordException e) {
            e.printStackTrace();
        }finally {

        }
    }
}
